/*
 * RegistrarVent.java
 *
 * Created on 10 de abril de 2008, 08:52 AM
 */

package mascotrin;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.text.MaskFormatter;
/**
 *
 * @author  SQL
 */
public class RegistrarVent extends javax.swing.JPanel {
    
    /** Creates new form RegistrarVent */
    public RegistrarVent() {
        initComponents();
         TextoVenta();
    }
    JFormattedTextField cantidad;
    JFormattedTextField fecha;
    MaskFormatter   mask;
    public void TextoVenta(){
         try{
         JLabel lblFecha = new JLabel();
         lblFecha.setText("Fecha");
          mask = new MaskFormatter("##/##/####");
        //  mask.setValidCharacters(".");
         cantidad = new JFormattedTextField(new Double(0));
         fecha = new JFormattedTextField(mask);
         DatosVenta.add(cantidad);
         DatosVenta.add(lblFecha);
         DatosVenta.add(fecha);
        }
        catch (java.text.ParseException e) {
            
        }
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        DatosVenta = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));

        DatosVenta.setLayout(new java.awt.GridLayout(6, 2, 0, 15));

        jLabel1.setText("Folio");
        DatosVenta.add(jLabel1);
        DatosVenta.add(jTextField1);

        jLabel2.setText("IdProducto");
        DatosVenta.add(jLabel2);
        DatosVenta.add(jTextField2);

        jLabel3.setText("IdCliente");
        DatosVenta.add(jLabel3);
        DatosVenta.add(jTextField3);

        jLabel4.setText("Mascota");
        DatosVenta.add(jLabel4);
        DatosVenta.add(jTextField4);

        jLabel5.setText("Cantidad");
        DatosVenta.add(jLabel5);

        add(DatosVenta);

        jButton1.setText("Registrar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        add(jButton1);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        String folio = jTextField1.getText();//folio
        String idproducto = jTextField2.getText();//idproducto
        String idcliente = jTextField3.getText();//idcliente
        String mascota = jTextField4.getText();//mascota
        Integer cantida = Integer.parseInt(cantidad.getText());//cantidad
        String fechaV = fecha.getText();//fecha
        String SQL = "INSERT INTO Venta VALUES('"+folio+"','"+idproducto+"','"+idcliente+"','"+mascota+"','"+cantida+"','"+fechaV+"')";
        CambiosSQL sqlRV = new CambiosSQL(SQL);
        jTextField1.setText("");
        jTextField2.setText("");
        jTextField3.setText("");
        jTextField4.setText("");
        cantidad.setText("");
        fecha.setText("00/00/0000");
    }//GEN-LAST:event_jButton1ActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel DatosVenta;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    // End of variables declaration//GEN-END:variables
    
}
